#include "Request.h"
#include "Logger.h"
#include <ctime>
#include <map>
#include <string>
#include <fstream>

class File;

const std::string c_strUserDire = "/user";
const int c_CachSize 			= 4;

class Cache
{


		File* m_Cache[ c_CachSize ];
		int	m_iSmallestElement;
		int	m_Index;
		time_t m_smallestTime;
		Logger&	LOGGER;

public:
		Cache(Logger& );
		void	Insert( File* );
		File*	Retreive( int );
		int		FindOldest();
};


class FileSystem
{

	std::map< int, File* >	m_Files;
	Logger&					LOGGER;
	Logger&					ERRLOGGER;
	Cache					cache;


public:

	FileSystem( Logger& , Logger&  );

	bool StoreFile(  int  );
	bool RetreiveFile(  int  );
	bool AuthenticateFile( int ID, std::string IPAddress);//Used by the Authenticatyion thread for Authenticating requests.
	bool CreateFile( Request* );
	//Used to create System files
	bool CreateFile( std::string , std::string , bool , int );
	bool UpdateFiles( Request* );
	bool IsUserDirectory( std::string );
	bool HandleStore( Request* );
	bool HandleRetrv( Request* );

};
